import * as echarts from 'echarts';

const BarType = (list: any, barNode: HTMLElement) => {
  // const rightCitysNode = document.getElementById('rightCitys') as HTMLElement;

  const rightCitys = echarts.init(barNode);
  console.log(list);
  const rightOption = {
    dataset: {
      source: list.map((data: any) => {
        return [data.name, data.value]; //超过15000的省份做了判断否则看不到其他省份的明显数据> 15000 ? 15000 : data.value
      }),
    },
    grid: { containLabel: false },
    xAxis: { name: '确诊人数' },
    yAxis: { name: '省份', type: 'category' },
    tooltip: {
      trigger: 'item',
      showDelay: 0,
      transitionDuration: 0.2,
    },
    series: [
      {
        type: 'bar',
        encode: {
          // Map the "amount" column to X axis.
          x: 1, //
          // Map the "product" column to Y axis
          y: 0,
        },
      },
    ],
  };

  rightCitys.setOption(rightOption);
};

export default BarType;
